home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / linux-boot-probes / mounted / 40grub next >
Encoding:
Text File  |  2007-03-14  |  1.7 KB  |  91 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3. set -e
  4.  
  5. partition="$1"
  6. bootpart="$2"
  7. mpoint="$3"
  8. type="$4"
  9.  
  10. found_item=0
  11.  
  12. entry_result () {
  13.     if [ -n "$kernel" ] && \
  14.        [ -e "$mpoint/$kernel" ]; then
  15.         result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
  16.         found_item=1
  17.     fi
  18.     kernel=""
  19.     parameters=""
  20.     initrd=""
  21.     title=""
  22. }
  23.  
  24. parse_grub_menu () {
  25.     mpoint="$1"
  26.     rootpart="$2"
  27.     bootpart="$3"
  28.     
  29.     kernel=""
  30.     parameters=""
  31.     initrd=""
  32.     title=""
  33.  
  34.     while read line; do
  35.         debug "parsing: $line"
  36.         set -- $line
  37.         case "$1" in
  38.             title)
  39.                 entry_result
  40.                 shift 1
  41.                 title="$(echo $@ | sed 's/://g')"
  42.             ;;
  43.             kernel)
  44.                 # Hack alert: sed off any (hdn,n) but
  45.                 # assume the kernel is on the same
  46.                 # partition.
  47.                 kernel="$(echo $2 | sed 's/(.*)//')"
  48.                 shift 2
  49.                 parameters="$@"
  50.                 # Systems with a separate /boot will not have
  51.                 # the path to the kernel in menu.lst.
  52.                 if [ "$partition" != "$bootpart" ]; then
  53.                     kernel="/boot$kernel"
  54.                 fi
  55.             ;;
  56.             initrd)
  57.                 initrd="$2"
  58.                 # Initrd same.
  59.                 if [ "$partition" != "$bootpart" ]; then
  60.                     initrd="/boot$initrd"
  61.                 fi
  62.             ;;
  63.             boot)
  64.                 entry_result
  65.             ;;
  66.             module)
  67.                 log "Skipping entry '$title':"
  68.                 log "parsing of entries containing 'module' lines is currently not supported"
  69.                 # Emptying kernel will invalidate the entry
  70.                 kernel=""
  71.             ;;
  72.         esac
  73.     done
  74.  
  75.     entry_result
  76. }
  77.  
  78. if [ -e "$mpoint/boot/grub/menu.lst" ]; then
  79.     debug "parsing menu.lst"
  80.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/menu.lst"
  81. elif [ -e "$mpoint/boot/grub/grub.conf" ]; then
  82.     debug "parsing grub.conf"
  83.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.conf"
  84. fi
  85.  
  86. if [ "$found_item" = 0 ]; then
  87.     exit 1
  88. else
  89.     exit 0
  90. fi
  91.